#include "AllDef.h"
#include "DrawList.h"
#include "vec3.h"
#include <Math.h>

DrawList::DrawList():list_id(0),need_redraw(1)
{}

DrawList::~DrawList()
{
	if(list_id)glDeleteLists(list_id,1);

}

void DrawList::Draw()
{
	if(need_redraw)
	{
		BeginList();
		PureDraw();
		EndList();
		need_redraw  = false;
	}else
		glCallList(list_id);
}

void DrawList::BeginList()
{
	if(list_id)glDeleteLists(list_id,1);
	list_id = glGenLists(1);
	glNewList(list_id, GL_COMPILE);
}

void DrawList::EndList()
{
	if(list_id)glEndList();
}


///

SimpleDrawList::SimpleDrawList():list_id(0)
{}

SimpleDrawList::~SimpleDrawList()
{
	if(list_id)glDeleteLists(list_id,1);

}

void SimpleDrawList::Draw()
{
	if(list_id)glCallList(list_id);
}

void SimpleDrawList::BeginList()
{
	if(list_id)glDeleteLists(list_id,1);
	list_id = glGenLists(1);
	glNewList(list_id, GL_COMPILE);
}

void SimpleDrawList::EndList()
{
	if(list_id)glEndList();
}
